import pygame

from Actor.Lead_actor import Lead_Actor
from Actor.PrizesSprite import PrizesSprite
from Actor.japanese_soldier import JapaneseWalkSoldier
from Actor.Chinese_soldier import ChineseFireSoldier


def create_sprite(tiled_map_data, obstacle_group, japanese_group, prizes_group):
    xiao_tie = None
    captain = None
    vice_captain = None
    for group in tiled_map_data.objectgroups:
        if group.name == "敌人":
            for obj in group:
                japanese = JapaneseWalkSoldier(obj.x, obj.y)
                japanese_group.add(japanese)
        elif group.name == "物品":
            for obj in group:
                prizes = PrizesSprite(obj.x, obj.y)
                prizes.rect = pygame.Rect(obj.x, obj.y, obj.width, obj.height)
                prizes_group.add(prizes)
                print(obj.x, obj.y, obj.width, obj.height)
        elif group.name == "障碍物":
            for obj in group:
                obstacle = pygame.sprite.Sprite()
                obstacle.rect = pygame.Rect(obj.x, obj.y, obj.width, obj.height)
                obstacle_group.add(obstacle)
        elif group.name == "主角":
            for obj in group:
                if obj.name == "队长":
                    captain = ChineseFireSoldier(obj.x, obj.y)
                    # 借用一下哦哦
                if obj.name == "副队长":
                    vice_captain = ChineseFireSoldier(obj.x, obj.y)
                if obj.name == "鱼儿":
                    xiao_tie = Lead_Actor(obj.x, obj.y)
    return xiao_tie, captain, vice_captain
